﻿#include "FTabBar.h"
#include "../Base/FTheme.h"


FTabBar::FTabBar(QWidget *parent)
    : QTabBar{parent}
{
    setBarStyle1();
}

void FTabBar::setBarStyle1()
{
    QString qss = QString(R"(
FTabBar::tab {
    background: transparent;
    border: none;
    padding: 0px 0px 0px 0px;
    margin: 4px 10px;
}
FTabBar::tab:selected,
FTabBar::tab:selected:hover {
    color: %1;
    font-weight: 600;
    border-bottom: 2px solid %1;
}
FTabBar::tab:!selected {
    border-bottom: 2px solid transparent;
}
FTabBar::tab:hover {
    border-bottom: 2px solid %2;
}
)").arg(FColors::getTextColor().name(QColor::HexArgb),
        FColors::getHoverColor(FColors::Default).name(QColor::HexArgb));

    setStyleSheet(qss);
}

void FTabBar::setBarStyle2()
{
    QString qss = QString(R"(
FTabBar::tab {
    background: transparent;
    border: none;
    padding: 6px 10px;
    margin: 0 2px;
}
FTabBar::tab:selected {
    color: %1;
    border-bottom: 2px solid %1;
    font-weight: 600;
}
FTabBar::tab:has-icon {
    padding-left: 10px;
}
)").arg(FColors::getTextColor().name(QColor::HexArgb));

    setStyleSheet(qss);
}

QSize FTabBar::tabSizeHint(int index) const
{
    QSize s = QTabBar::tabSizeHint(index);
    s.rwidth() += 10; // extra padding for bold text
    return s;
}
